<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <title>Document</title>
    <script src="./ezuikit.js"></script>
    <style>
        html, body {
            padding: 0;
            margin: 0;
            text-align: center;
            background: #00000080;
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div id="video-container"></div>
    <script>
        //播放器模板
        var themeData = {
            "poster": "./bg.png",
            header: {
                color: "#1890ff",
                activeColor: "#FFFFFF",
                backgroundColor: "#000000",
                btnList: [
                    {
                        iconId: "deviceID",
                        part: "left",
                        defaultActive: 0,
                        memo: "顶部设备序列号",
                        isrender: 1
                    },
                    {
                        iconId: "deviceName",
                        part: "left",
                        defaultActive: 0,
                        memo: "顶部设备名称",
                        isrender: 1
                    },
                    {
                        iconId: "cloudRec",
                        part: "right",
                        defaultActive: 0,
                        memo: "云存储",
                        isrender: 0
                    },
                    {
                        iconId: "rec",
                        part: "right",
                        defaultActive: 0,
                        memo: "SD卡回放",
                        isrender: 0
                    }
                ]
            },
            footer: {
                color: "#FFFFFF",
                activeColor: "#1890FF",
                backgroundColor: "#00000021",
                btnList: [
                    {
                        iconId: "play",
                        part: "left",
                        defaultActive: 1,
                        memo: "播放",
                        isrender: 1
                    },
                    {
                        iconId: "capturePicture",
                        part: "left",
                        defaultActive: 0,
                        memo: "截屏按钮",
                        isrender: 1
                    },
                    {
                        iconId: "sound",
                        part: "left",
                        defaultActive: 0,
                        memo: "声音按钮",
                        isrender: 1
                    },
                    {
                        iconId: "pantile",
                        part: "left",
                        defaultActive: 0,
                        memo: "云台控制按钮",
                        isrender: 1
                    },
                    {
                        iconId: "recordvideo",
                        part: "left",
                        defaultActive: 0,
                        memo: "录制按钮",
                        isrender: 1
                    },
                    {
                        iconId: "talk",
                        part: "left",
                        defaultActive: 0,
                        memo: "对讲按钮",
                        isrender: 1
                    },
                    {
                        iconId: "zoom",
                        part: "left",
                        defaultActive: 0,
                        memo: "电子放大",
                        isrender: 1
                    },
                    {
                        iconId: "hd",
                        part: "left",
                        defaultActive: 0,
                        memo: "清晰度切换按钮",
                        isrender: 1
                    }
                ]
            }
        };
        var domain = "https://open.ys7.com";
        var EZOPENPlayer;
        //window.EZOPENPlayer = EZOPENPlayer;
        var width = document.documentElement.clientWidth;
        var height = document.documentElement.clientHeight;
        function ezopenInit(deviceSerial, deviceCode, accessToken) {
            if (EZOPENPlayer) {
                destroy()
            }
            deviceCode = deviceCode === "" ? "" : deviceCode + "@";
            var playUrl =
                "ezopen://" +
                deviceCode +
                "open.ys7.com/" +
                deviceSerial +
                "/1.live";
            try {
                EZOPENPlayer = new EZUIKit.EZUIKitPlayer({
                    id: "video-container",
                    autoplay: true,
                    width: width,
                    height: height,
                    //template: "pcLive",
                    url: playUrl,
                    accessToken: accessToken,
                    themeData: themeData, //模板对象内容
					env: {
					  // https://open.ys7.com/help/1772?h=domain
					  // domain默认是 https://open.ys7.com, 如果是私有化部署或海外的环境，请配置对应的domain
					  // The default domain is https://open.ys7.com If it is a private deployment or overseas (outside of China) environment, please configure the corresponding domain
					  domain: "https://open.ys7.com",
					},
                    handleError: (err) => {
                        if (err.type === "handleRunTimeInfoError" &&err.data.nErrorCode === 5 ) {
                            // 加密设备密码错误
                            alert("视频播放失败！！！");
                        }
                    }
                });
            } catch (error) {
                // 使用alert进行错误提示
                alert("播放器初始化错误： " + error);
            }
        }
        function destroy() {
            if (EZOPENPlayer) {
                EZOPENPlayer.destroy()
            }
            EZOPENPlayer = null
        }
        // ezopenInit();

        document.onkeydown = function (e) {
            e = window.event || e;
            var k = e.keyCode;
            //屏蔽ctrl+R，F5键，ctrl+F5键  F3键
            if ((e.ctrlKey == true && k == 82) || (k == 116) ||
                (e.ctrlKey == true && k == 116) || k == 114) {
                e.keyCode = 0;
                e.returnValue = false;
                e.cancelBubble = true;
                return false;

            }
            if (k == 8) {
                e.keyCode = 0;
                e.returnValue = false;
                return false;
            }
            //屏蔽 Ctrl+n
            if (e.ctrlKey && k == 78) {
                e.keyCode = 0;
                e.returnValue = false;
                e.cancelBubble = true;
                return false;
            }
            //屏蔽F12
            if (k == 123) {
                e.keyCode = 0;
                e.returnValue = false;
                e.cancelBubble = true;
                return false;
            }
            //屏蔽F11
            if (k == 122) {
                e.keyCode = 0;
                e.returnValue = false;
                e.cancelBubble = true;
                return false;
            }
            //屏蔽 shift+F10    
            if ((e.shiftKey && k == 121) || (e.ctrlKey && k == 121)) {
                e.keyCode = 0;
                e.returnValue = false;
                e.cancelBubble = true;
                return false;
            }
            //屏蔽F17
            if (k == 118) {
                e.keyCode = 0;
                e.returnValue = false;
                e.cancelBubble = true;
                return false;
            }
            //屏蔽Alt+F4  
            if ((e.altKey) && (k == 115)) {
                window.showModelessDialog("about:blank", "",
                    "dialogWidth:1px;dialogheight:1px");
                e.keyCode = 0;
                e.returnValue = false;
                e.cancelBubble = true;
                return false;
            }
            //屏蔽 Alt+ 方向键 ← ;屏蔽 Alt+ 方向键 →
            if ((e.altKey) &&
                ((k == 37) || (k == 39))) {
                e.keyCode = 0;
                e.returnValue = false;
                e.cancelBubble = true;
                return false;
            }

        };
        //屏蔽右键菜单
        document.oncontextmenu = function (event) {
            if (window.event) {
                event = window.event;
            }
            try {
                var the = event.srcElement;
                if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
                    return false;
                }
                return true;
            } catch (e) {
                return false;
            }
        };
    </script>
</body>

</html>
